﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NMortgage.UI.Model;
using NMortgage.UI.ViewModels;

namespace NMortgage.UI.Tests.ViewModels
{
    [TestClass]
    public class PeriodicPaymentViewModelTest 
    {
        private PeriodicPaymentViewModel Subject { get; set; }
        private PeriodicPayment Payment { get; set; }
        private DateTime ExpectedPaymentDate { get; set; }
        [TestInitialize]
        public void Initialize()
        {
            ExpectedPaymentDate = new DateTime(2011, 1, 1);

            Payment = new PeriodicPayment()
                          {
                              Period = 1,
                              BeginingBalance = 1,
                              EndingBalance = 1,
                              CumulativeInterest = 1,
                              CumulativePrincipal = 1,
                              InterestDue = 1,
                              StandardPayment = 1,
                              PrincipleDue = 1,
                              PaymentDate = ExpectedPaymentDate
                          };
            Subject = new PeriodicPaymentViewModel(Payment, new MortgageProfile());
        }
        [TestMethod]
        public void Period()
        {
            Assert.AreEqual(1, Subject.Period);
        }
        [TestMethod]
        public void BeginingBalance()
        {
            TestProxyProperty(x => x.BeginingBalance);
        }
        [TestMethod]
        public void PaymentMade()
        {
            TestProxyProperty(x => x.PaymentMade);
        }
        [TestMethod]
        public void PrincipleDue()
        {
            TestProxyProperty(x => x.PrincipleDue);
        }
        [TestMethod]
        public void InterestDue()
        {
            TestProxyProperty(x => x.InterestDue);
        }
        [TestMethod]
        public void EndingBalance()
        {
            TestProxyProperty(x => x.EndingBalance);
        }
        [TestMethod]
        public void CumulativePrincipal()
        {
            TestProxyProperty(x => x.CumulativePrincipal);
        }
        [TestMethod]
        public void CumulativeInterest()
        {
            TestProxyProperty(x => x.CumulativeInterest);
        }
        [TestMethod]
        public void PaymentDate()
        {
            Assert.AreEqual(ExpectedPaymentDate, Subject.PaymentDate);
        }

        private void TestProxyProperty<T>(Func<PeriodicPaymentViewModel, T> property)
        {
            var expected = 1.0;
            var actual = property(Subject);
            Assert.AreEqual(expected, actual);
        }

       
    }
}
